// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.radio;

import java.util.Map;
import java.util.Map.Entry;
import se.krka.kahlua.vm.KahluaTable;
import zombie.Lua.LuaManager;

public final class RadioAPI {
    private static RadioAPI instance;

    public static int timeToTimeStamp(int days, int hours, int minutes) {
        return days * 24 + hours * 60 + minutes;
    }

    public static int timeStampToDays(int stamp) {
        return stamp / 1440;
    }

    public static int timeStampToHours(int stamp) {
        return stamp / 60 % 24;
    }

    public static int timeStampToMinutes(int stamp) {
        return stamp % 60;
    }

    public static boolean hasInstance() {
        return instance != null;
    }

    public static RadioAPI getInstance() {
        if (instance == null) {
            instance = new RadioAPI();
        }

        return instance;
    }

    private RadioAPI() {
    }

    public KahluaTable getChannels(String string) {
        Map map = ZomboidRadio.getInstance().GetChannelList(string);
        KahluaTable kahluaTable = LuaManager.platform.newTable();
        if (map != null) {
            for (Entry entry : map.entrySet()) {
                kahluaTable.rawset(entry.getKey(), entry.getValue());
            }
        }

        return kahluaTable;
    }
}
